using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ShivamEMR.Model.Domain.PharmacyDomain;
using ShivamEMR.Model.DataInterfaces.PharmacyDataInterf;
using ShivamEMR.Model;
//using ShivamEMR.Web.Areas.Pharmacy.Models;

namespace ShivamEMR.Web.Areas.Pharmacy.Controllers
{   
    public class DrugInteractionController : Controller
    {
		private readonly IDrugInteractionRepository druginteractionRepository;

		// If you are using Dependency Injection, you can delete the following constructor
        public DrugInteractionController() 
        {
            druginteractionRepository = Registry.RepositoryFactory.GetDrugInteractionRepository();
        }

        public DrugInteractionController(IDrugInteractionRepository druginteractionRepository)
        {
			this.druginteractionRepository = druginteractionRepository;
        }

        //
        // GET: /DrugInteraction/

        public ViewResult Index()
        {
            return View(druginteractionRepository.All);
        }

        //
        // GET: /DrugInteraction/Details/5

        public ViewResult Details(System.Guid id)
        {
            return View(druginteractionRepository.Find(id));
        }

        //
        // GET: /DrugInteraction/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /DrugInteraction/Create

        [HttpPost]
        public ActionResult Create(DrugInteraction druginteraction)
        {
            if (ModelState.IsValid) {
                druginteractionRepository.InsertOrUpdate(druginteraction);
                druginteractionRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }
        
        //
        // GET: /DrugInteraction/Edit/5
 
        public ActionResult Edit(System.Guid id)
        {
             return View(druginteractionRepository.Find(id));
        }

        //
        // POST: /DrugInteraction/Edit/5

        [HttpPost]
        public ActionResult Edit(DrugInteraction druginteraction)
        {
            if (ModelState.IsValid) {
                druginteractionRepository.InsertOrUpdate(druginteraction);
                druginteractionRepository.Save();
                return RedirectToAction("Index");
            } else {
				return View();
			}
        }

        //
        // GET: /DrugInteraction/Delete/5
 
        public ActionResult Delete(System.Guid id)
        {
            return View(druginteractionRepository.Find(id));
        }

        //
        // POST: /DrugInteraction/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(System.Guid id)
        {
            var drugint = druginteractionRepository.Find(id);
            druginteractionRepository.Delete(drugint);
            druginteractionRepository.Save();

            return RedirectToAction("Index");
        }
    }
}

